package io.polly.common.config;

import io.polly.common.constant.DynamicExecutorConstant;
import io.polly.common.constant.NotifyTypeEnum;
import io.polly.common.constant.QueueTypeEnum;
import io.polly.common.constant.RejectedTypeEnum;
import io.polly.common.entity.NotifyItem;
import lombok.Data;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author ldz
 * @version V1.0
 * @title: ThreadPoolProperties
 * @description: TODO(用一句话描述该文件做什么)
 * @date: 2022/3/18 21:06
 */
@Data
public class ThreadPoolProperties {

    private String threadPoolName = DynamicExecutorConstant.DYNAMIC_EXECUTOR_NAME;

    /**
     * CoreSize of ThreadPool.
     */
    private int corePoolSize = 1;


    private int maximumPoolSize = DynamicExecutorConstant.AVAILABLE_PROCESSORS;


    private int queueCapacity = 1024;


    private String queueType = QueueTypeEnum.LINKED_BLOCKING_QUEUE.getName();


    private String rejectedHandlerType = RejectedTypeEnum.ABORT_POLICY.getName();


    private long keepAliveTime = 30;


    private TimeUnit unit = TimeUnit.SECONDS;

    /** for SynchronousQueue */
    private boolean fair = false;

    private String executorNamePrefix ="dynamic-executor-";

    /**
     * Notify items, see {@link NotifyTypeEnum}
     */
    private List<NotifyItem> notifyItems;

    private boolean allowCoreThreadTimeOut = false;
}
